//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.baidu.trace;

import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import com.baidu.trace.api.analysis.DrivingBehaviorRequest;
import com.baidu.trace.api.analysis.DrivingBehaviorResponse;
import com.baidu.trace.api.analysis.EndPoint;
import com.baidu.trace.api.analysis.HarshAccelerationPoint;
import com.baidu.trace.api.analysis.HarshBreakingPoint;
import com.baidu.trace.api.analysis.HarshSteeringPoint;
import com.baidu.trace.api.analysis.OnAnalysisListener;
import com.baidu.trace.api.analysis.SpeedingInfo;
import com.baidu.trace.api.analysis.SpeedingPoint;
import com.baidu.trace.api.analysis.StartPoint;
import com.baidu.trace.api.analysis.StayPoint;
import com.baidu.trace.api.analysis.StayPointRequest;
import com.baidu.trace.api.analysis.StayPointResponse;
import com.baidu.trace.api.analysis.ThresholdOption;
import com.baidu.trace.api.analysis.TurnType;
import com.baidu.trace.api.bos.BosGeneratePresignedUrlRequest;
import com.baidu.trace.api.bos.BosGeneratePresignedUrlResponse;
import com.baidu.trace.api.bos.BosGetObjectRequest;
import com.baidu.trace.api.bos.BosGetObjectResponse;
import com.baidu.trace.api.bos.BosPutObjectRequest;
import com.baidu.trace.api.bos.BosPutObjectResponse;
import com.baidu.trace.api.bos.OnBosListener;
import com.baidu.trace.api.entity.AddEntityRequest;
import com.baidu.trace.api.entity.AddEntityResponse;
import com.baidu.trace.api.entity.AroundSearchRequest;
import com.baidu.trace.api.entity.BoundSearchRequest;
import com.baidu.trace.api.entity.CommonRequest;
import com.baidu.trace.api.entity.CommonResponse;
import com.baidu.trace.api.entity.DeleteEntityRequest;
import com.baidu.trace.api.entity.DeleteEntityResponse;
import com.baidu.trace.api.entity.DistrictSearchRequest;
import com.baidu.trace.api.entity.DistrictSearchResponse;
import com.baidu.trace.api.entity.EntityInfo;
import com.baidu.trace.api.entity.EntityListRequest;
import com.baidu.trace.api.entity.LatestLocation;
import com.baidu.trace.api.entity.LocRequest;
import com.baidu.trace.api.entity.OnEntityListener;
import com.baidu.trace.api.entity.PolygonSearchRequest;
import com.baidu.trace.api.entity.SearchRequest;
import com.baidu.trace.api.entity.UpdateEntityRequest;
import com.baidu.trace.api.entity.UpdateEntityResponse;
import com.baidu.trace.api.fence.AlarmPoint;
import com.baidu.trace.api.fence.CircleFence;
import com.baidu.trace.api.fence.CreateFenceRequest;
import com.baidu.trace.api.fence.CreateFenceResponse;
import com.baidu.trace.api.fence.DeleteFenceRequest;
import com.baidu.trace.api.fence.DeleteFenceResponse;
import com.baidu.trace.api.fence.DistrictFence;
import com.baidu.trace.api.fence.Fence;
import com.baidu.trace.api.fence.FenceAlarmInfo;
import com.baidu.trace.api.fence.FenceInfo;
import com.baidu.trace.api.fence.FenceListRequest;
import com.baidu.trace.api.fence.FenceListResponse;
import com.baidu.trace.api.fence.FenceShape;
import com.baidu.trace.api.fence.FenceType;
import com.baidu.trace.api.fence.HistoryAlarmRequest;
import com.baidu.trace.api.fence.HistoryAlarmResponse;
import com.baidu.trace.api.fence.MonitoredAction;
import com.baidu.trace.api.fence.MonitoredStatus;
import com.baidu.trace.api.fence.MonitoredStatusByLocationRequest;
import com.baidu.trace.api.fence.MonitoredStatusByLocationResponse;
import com.baidu.trace.api.fence.MonitoredStatusInfo;
import com.baidu.trace.api.fence.MonitoredStatusRequest;
import com.baidu.trace.api.fence.MonitoredStatusResponse;
import com.baidu.trace.api.fence.OnFenceListener;
import com.baidu.trace.api.fence.PolygonFence;
import com.baidu.trace.api.fence.PolylineFence;
import com.baidu.trace.api.fence.UpdateFenceRequest;
import com.baidu.trace.api.fence.UpdateFenceResponse;
import com.baidu.trace.api.track.AddPointRequest;
import com.baidu.trace.api.track.AddPointResponse;
import com.baidu.trace.api.track.AddPointsRequest;
import com.baidu.trace.api.track.AddPointsResponse;
import com.baidu.trace.api.track.DistanceRequest;
import com.baidu.trace.api.track.DistanceResponse;
import com.baidu.trace.api.track.FailInfo;
import com.baidu.trace.api.track.HistoryTrackRequest;
import com.baidu.trace.api.track.HistoryTrackResponse;
import com.baidu.trace.api.track.LatestPoint;
import com.baidu.trace.api.track.LatestPointRequest;
import com.baidu.trace.api.track.LatestPointResponse;
import com.baidu.trace.api.track.OnTrackListener;
import com.baidu.trace.api.track.SupplementMode;
import com.baidu.trace.api.track.TrackPoint;
import com.baidu.trace.api.track.FailInfo.InternalError;
import com.baidu.trace.api.track.FailInfo.ParamError;
import com.baidu.trace.c.e;
import com.baidu.trace.c.h;
import com.baidu.trace.c.a.c;
import com.baidu.trace.model.BaseRequest;
import com.baidu.trace.model.BaseResponse;
import com.baidu.trace.model.CoordType;
import com.baidu.trace.model.LatLng;
import com.baidu.trace.model.Point;
import com.baidu.trace.model.ProcessOption;
import com.baidu.trace.model.SortType;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class a {
    public int a;
    public int b;
    public int c;
    public int d;
    public char e;

    protected static void a(StayPointRequest var0, OnAnalysisListener var1) {
        a(var0, var0.getEntityName(), var0.getServiceId(), var0.getStartTime(), var0.getEndTime(), "analysis/staypoint", 1, var0.getStayTime(), var0.getStayRadius(), 0, (ThresholdOption)null, var0.getProcessOption(), var0.getCoordTypeOutput(), var1);
    }

    protected static void a(DrivingBehaviorRequest var0, OnAnalysisListener var1) {
        a(var0, var0.getEntityName(), var0.getServiceId(), var0.getStartTime(), var0.getEndTime(), "analysis/drivingbehavior", 2, 0, 0, var0.getSpeedingThreshold(), var0.getThresholdOption(), var0.getProcessOption(), var0.getCoordTypeOutput(), var1);
    }

    private static void a(BaseRequest var0, String var1, long var2, long var4, long var6, String var8, int var9, int var10, int var11, int var12, ThresholdOption var13, ProcessOption var14, CoordType var15, OnAnalysisListener var16) {
        if(!e.a(var1)) {
            if(var0 instanceof StayPointRequest) {
                StayPointResponse var20 = new StayPointResponse(var0.getTag(), 2, "entityName参数错误");
                var16.onStayPointCallback(var20);
            } else {
                if(var0 instanceof DrivingBehaviorRequest) {
                    DrivingBehaviorResponse var19 = new DrivingBehaviorResponse(var0.getTag(), 2, "entityName参数错误");
                    var16.onDrivingBehaviorCallback(var19);
                }

            }
        } else {
            TreeMap var17 = new TreeMap();

            try {
                var17.put("entity_name", URLEncoder.encode(var1, "UTF-8"));
            } catch (Exception var18) {
                var17.put("entity_name", var1);
            }

            if(var4 > 0L) {
                var17.put("start_time", String.valueOf(var4));
            }

            if(var6 > 0L) {
                var17.put("end_time", String.valueOf(var6));
            }

            if(var10 > 0) {
                var17.put("stay_time", String.valueOf(var10));
            }

            if(var11 > 0) {
                var17.put("stay_radius", String.valueOf(var11));
            }

            if(var13 != null) {
                if(var13.getSpeedingThreshold() > 0.0D) {
                    var17.put("speeding_threshold", String.valueOf(var13.getSpeedingThreshold()));
                }

                if(var13.getHarshAccelerationThreshold() > 0.0D) {
                    var17.put("harsh_acceleration_threshold", String.valueOf(var13.getHarshAccelerationThreshold()));
                }

                if(var13.getHarshBreakingThreshold() < 0.0D) {
                    var17.put("harsh_breaking_threshold", String.valueOf(var13.getHarshBreakingThreshold()));
                }

                if(var13.getHarshSteeringThreshold() > 0.0D) {
                    var17.put("harsh_steering_threshold", String.valueOf(var13.getHarshSteeringThreshold()));
                }
            }

            if(var12 > 0) {
                var17.put("speeding_threshold", String.valueOf(var12));
            }

            a(var14, var17);
            if(var15 != null) {
                var17.put("coord_type_output", var15.name());
            }

            com.baidu.trace.c.a.a(var0, 4, var8, c.a, var9, a(var17, var2, c.a), var16);
            var17.clear();
        }
    }

    public static void a(BaseRequest var0, int var1, boolean var2, int var3, String var4, OnAnalysisListener var5) {
        int var6 = var0.getTag();
        switch(var1) {
            case 1:
                StayPointResponse var13 = new StayPointResponse(var6, var3, var4);
                if(var2) {
                    StayPointResponse var17 = var13;
                    String var15 = var4;

                    try {
                        JSONObject var18 = new JSONObject(var15);
                        if(b(var15, var17)) {
                            if(var18.has("staypoint_num")) {
                                var17.setStayPointNum(var18.getInt("staypoint_num"));
                            }

                            ArrayList var16 = new ArrayList();
                            if(var18.has("stay_points")) {
                                JSONArray var19;
                                int var20 = (var19 = var18.getJSONArray("stay_points")).length();

                                for(var6 = 0; var6 < var20; ++var6) {
                                    StayPoint var7 = new StayPoint();
                                    JSONObject var8;
                                    if((var8 = var19.getJSONObject(var6)).has("start_time")) {
                                        var7.setStartTime(var8.getLong("start_time"));
                                    }

                                    if(var8.has("end_time")) {
                                        var7.setEndTime(var8.getLong("end_time"));
                                    }

                                    if(var8.has("duration")) {
                                        var7.setDuration(var8.getInt("duration"));
                                    }

                                    if(var8.has("stay_point")) {
                                        if((var8 = var8.getJSONObject("stay_point")).has("longitude") && var8.has("latitude")) {
                                            var7.setLocation(new LatLng(var8.getDouble("latitude"), var8.getDouble("longitude")));
                                        }

                                        if(var8.has("coord_type")) {
                                            var7.setCoordType(CoordType.valueOf(var8.getString("coord_type")));
                                        }
                                    }

                                    var16.add(var7);
                                }
                            }

                            var17.setStayPoints(var16);
                        }
                    } catch (Exception var11) {
                        ;
                    } finally {
                        ;
                    }
                }

                var5.onStayPointCallback(var13);
                return;
            case 2:
                DrivingBehaviorResponse var14 = new DrivingBehaviorResponse(var6, var3, var4);
                if(var2) {
                    a(var4, ((DrivingBehaviorRequest)var0).getCoordTypeOutput(), var14);
                }

                var5.onDrivingBehaviorCallback(var14);
            default:
        }
    }

    private a(f var1) {
        this.a = -1;
        this.b = -1;
        this.c = -1;
        this.d = -1;
        this.e = 0;
    }

    private boolean b() {
        return this.a >= 0 && this.b > 0;
    }

    public String a() {
        if(!this.b()) {
            return null;
        } else {
            StringBuffer var1;
            (var1 = new StringBuffer(128)).append(this.e);
            var1.append("h");
            if(this.c != 460) {
                var1.append(this.c);
            }

            var1.append(String.format(Locale.CHINA, "h%xh%xh%x", new Object[]{Integer.valueOf(this.d), Integer.valueOf(this.a), Integer.valueOf(this.b)}));
            return var1.toString();
        }
    }

    public static void a(String var0) {
        if(Thread.currentThread().getStackTrace().length != 0) {
            h.a("INFO", var0);
        }
    }

    public static void a(String var0, String var1) {
        if(!TextUtils.isEmpty(var0) && !TextUtils.isEmpty(var1)) {
            Log.e(var0, var1);
        }
    }

    protected static void a(BosPutObjectRequest var0, OnBosListener var1) {
        if(TextUtils.isEmpty(var0.getObjectKey())) {
            BosPutObjectResponse var7 = new BosPutObjectResponse(var0.getTag(), 2, "objectKey参数错误");
            var1.onPutObjectCallback(var7);
        } else {
            long var2 = 0L;
            File var4;
            if(null != (var4 = var0.getFile())) {
                var2 = var4.length();
            } else {
                String var8;
                if(null != (var8 = var0.getStringData())) {
                    var2 = (long)var8.length();
                } else {
                    byte[] var9;
                    if(null != (var9 = var0.getByteArray())) {
                        var2 = (long)var9.length;
                    } else {
                        InputStream var10;
                        if(null != (var10 = var0.getStreamData())) {
                            try {
                                var2 = (long)var10.available();
                            } catch (IOException var6) {
                                ;
                            }
                        }
                    }
                }
            }

            var0.setObjectSize(var2);
            TreeMap var11 = new TreeMap();

            try {
                var11.put("object_key", URLEncoder.encode(var0.getObjectKey(), "UTF-8"));
            } catch (Exception var5) {
                var11.put("object_key", var0.getObjectKey());
            }

            if(null != var0.getObjectType()) {
                var11.put("object_type", var0.getObjectType().name());
            }

            var11.put("object_size", String.valueOf(var2 / 1024L));
            com.baidu.trace.c.a.a(var0, 3, "object/preparetoput", c.b, 1, a(var11, var0.getServiceId(), c.b), var1);
            var11.clear();
        }
    }

    protected static void a(BosGetObjectRequest var0, OnBosListener var1) {
        if(TextUtils.isEmpty(var0.getObjectKey())) {
            BosGetObjectResponse var4 = new BosGetObjectResponse(var0.getTag(), 2, "objectKey参数错误");
            var1.onGetObjectCallback(var4);
        } else {
            TreeMap var2 = new TreeMap();

            try {
                var2.put("object_key", URLEncoder.encode(var0.getObjectKey(), "UTF-8"));
            } catch (Exception var3) {
                var2.put("object_key", var0.getObjectKey());
            }

            if(null != var0.getObjectType()) {
                var2.put("object_type", var0.getObjectType().name());
            }

            com.baidu.trace.c.a.a(var0, 3, "object/preparetoget", c.b, 2, a(var2, var0.getServiceId(), c.b), var1);
            var2.clear();
        }
    }

    protected static void a(BosGeneratePresignedUrlRequest var0, OnBosListener var1) {
        if(TextUtils.isEmpty(var0.getObjectKey())) {
            BosGeneratePresignedUrlResponse var6 = new BosGeneratePresignedUrlResponse(var0.getTag(), 2, "objectKey参数错误");
            var1.onGeneratePresignedUrlCallback(var6);
        } else {
            TreeMap var2 = new TreeMap();

            try {
                var2.put("object_key", URLEncoder.encode(var0.getObjectKey(), "UTF-8"));
            } catch (Exception var5) {
                var2.put("object_key", var0.getObjectKey());
            }

            if(null != var0.getObjectType()) {
                var2.put("object_type", var0.getObjectType().name());
            }

            String var3;
            if(!TextUtils.isEmpty(var3 = com.baidu.trace.h.a(var0))) {
                try {
                    var2.put("image_command", URLEncoder.encode(var3, "UTF-8"));
                } catch (Exception var4) {
                    var2.put("image_command", var3);
                }
            }

            com.baidu.trace.c.a.a(var0, 3, "object/generatepresignedurl", c.b, 3, a(var2, var0.getServiceId(), c.b), var1);
            var2.clear();
        }
    }

    protected static void a(AddEntityRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(a(0, var0.getTag(), var0.getEntityName(), var0.getEntityDesc(), var0.getColumns(), var2, var1)) {
            com.baidu.trace.c.a.a(var0, 1, "entity/add", c.b, 2, a(var2, var0.getServiceId(), c.b), var1);
        }

        var2.clear();
    }

    protected static void a(UpdateEntityRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(a(1, var0.getTag(), var0.getEntityName(), var0.getEntityDesc(), var0.getColumns(), var2, var1)) {
            com.baidu.trace.c.a.a(var0, 1, "entity/update", c.b, 4, a(var2, var0.getServiceId(), c.b), var1);
        }

        var2.clear();
    }

    protected static void a(DeleteEntityRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(a(2, var0.getTag(), var0.getEntityName(), (String)null, (Map)null, var2, var1)) {
            com.baidu.trace.c.a.a(var0, 1, "entity/delete", c.b, 3, a(var2, var0.getServiceId(), c.b), var1);
        }

        var2.clear();
    }

    protected static void a(LocRequest var0, String var1, OnEntityListener var2) {
        TreeMap var3;
        (var3 = new TreeMap()).put("apinfo", var1);
        com.baidu.trace.c.a.a(var0, 1, "internal/androidlocate", c.b, 5, a(var3, var0.getServiceId(), c.b), var2);
        var3.clear();
    }

    protected static void a(EntityListRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        a(var0, var2, "entity/list", 1, var1);
        var2.clear();
    }

    protected static void a(SearchRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        String var3;
        if(e.a(var3 = var0.getKeyword())) {
            try {
                var2.put("query", URLEncoder.encode(var3, "UTF-8"));
            } catch (Exception var4) {
                var2.put("query", var3);
            }
        }

        a(var0, var2, "entity/search", 6, var1);
        var2.clear();
    }

    protected static void a(BoundSearchRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(null != var0.getCoordTypeInput()) {
            var2.put("coord_type_input", var0.getCoordTypeInput().name());
        }

        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        if(null != var0.getLowerLeft() && null != var0.getUpperRight()) {
            LatLng var3 = var0.getLowerLeft();
            LatLng var4 = var0.getUpperRight();
            StringBuffer var5;
            (var5 = new StringBuffer()).append(var3.latitude).append(",").append(var3.longitude).append(";");
            var5.append(var4.latitude).append(",").append(var4.longitude);
            var2.put("bounds", var5.toString());
        }

        a(var0, var2, "entity/boundsearch", 7, var1);
        var2.clear();
    }

    protected static void a(AroundSearchRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(null != var0.getCenter()) {
            LatLng var3 = var0.getCenter();
            StringBuffer var4;
            (var4 = new StringBuffer()).append(var3.latitude).append(",").append(var3.longitude);
            var2.put("center", var4.toString());
        }

        if(var0.getRadius() > 0.0D) {
            var2.put("radius", String.valueOf(var0.getRadius()));
        }

        if(null != var0.getCoordTypeInput()) {
            var2.put("coord_type_input", var0.getCoordTypeInput().name());
        }

        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        a(var0, var2, "entity/aroundsearch", 8, var1);
        var2.clear();
    }

    protected static void a(PolygonSearchRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(null != var0.getVertexes()) {
            aa.a(var0.getVertexes(), var2);
        }

        if(null != var0.getCoordTypeInput()) {
            var2.put("coord_type_input", var0.getCoordTypeInput().name());
        }

        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        a(var0, var2, "entity/polygonsearch", 9, var1);
        var2.clear();
    }

    protected static void a(DistrictSearchRequest var0, OnEntityListener var1) {
        TreeMap var2 = new TreeMap();
        if(!TextUtils.isEmpty(var0.getKeyword())) {
            try {
                var2.put("keyword", URLEncoder.encode(var0.getKeyword(), "UTF-8"));
            } catch (Exception var3) {
                var2.put("keyword", var0.getKeyword());
            }
        }

        if(null != var0.getReturnType()) {
            var2.put("return_type", var0.getReturnType().name());
        }

        if(null != var0.getCoordTypeOutput()) {
            var2.put("coord_type_output", var0.getCoordTypeOutput().name());
        }

        a(var0, var2, "entity/districtsearch", 10, var1);
        var2.clear();
    }

    private static void a(CommonRequest var0, TreeMap<String, String> var1, String var2, int var3, OnEntityListener var4) {
        aa.a(var0.getFilterCondition(), var1);
        aa.a(var0.getSortBy(), var1);
        e.a(var0.getPageIndex(), var0.getPageSize(), var1);
        com.baidu.trace.c.a.a(var0, 1, var2, c.a, var3, a(var1, var0.getServiceId(), c.a), var4);
    }

    protected static boolean a(int var0, int var1, String var2, String var3, Map<String, String> var4, TreeMap<String, String> var5, OnEntityListener var6) {
        if(!e.a(var2)) {
            if(var0 == 0) {
                AddEntityResponse var13 = new AddEntityResponse(var1, 2, "entityName参数错误");
                var6.onAddEntityCallback(var13);
            } else if(1 == var0) {
                UpdateEntityResponse var14 = new UpdateEntityResponse(var1, 2, "entityName参数错误");
                var6.onUpdateEntityCallback(var14);
            } else if(2 == var0) {
                DeleteEntityResponse var15 = new DeleteEntityResponse(var1, 2, "entityName参数错误");
                var6.onDeleteEntityCallback(var15);
            }

            return false;
        } else {
            try {
                var5.put("entity_name", URLEncoder.encode(var2, "UTF-8"));
            } catch (Exception var9) {
                var5.put("entity_name", var2);
            }

            if(!TextUtils.isEmpty(var3)) {
                try {
                    var5.put("entity_desc", URLEncoder.encode(var3, "UTF-8"));
                } catch (Exception var8) {
                    var5.put("entity_desc", var3);
                }
            }

            if(var4 != null && !var4.isEmpty()) {
                Iterator var12 = var4.entrySet().iterator();

                while(var12.hasNext()) {
                    Entry var16;
                    if(!e.b((String)(var16 = (Entry)var12.next()).getKey())) {
                        if(var0 == 0) {
                            AddEntityResponse var10 = new AddEntityResponse(var1, 2, "column_key参数错误");
                            var6.onAddEntityCallback(var10);
                        } else if(1 == var0) {
                            UpdateEntityResponse var11 = new UpdateEntityResponse(var1, 2, "column_key参数错误");
                            var6.onUpdateEntityCallback(var11);
                        }

                        return false;
                    }

                    if(!TextUtils.isEmpty((CharSequence)var16.getValue())) {
                        try {
                            var5.put(var16.getKey(), URLEncoder.encode((String)var16.getValue(), "UTF-8"));
                        } catch (Exception var7) {
                            var5.put(var16.getKey(), var16.getValue());
                        }
                    }
                }

                return true;
            } else {
                return true;
            }
        }
    }

    protected static void a(Context var0, IService var1, Handler var2, CreateFenceRequest var3, OnFenceListener var4) {
        if(FenceType.server == var3.getFence().getFenceType()) {
            Fence var5;
            if((var5 = var3.getFence()) instanceof CircleFence) {
                CircleFence var9 = (CircleFence)var5;
                a(var3, 1, FenceShape.circle, 0L, var9.getFenceName(), var9.getMonitoredPerson(), (String)null, var9.getCenter(), var9.getRadius(), (List)null, 0, var9.getCoordType(), var9.getDenoise(), var4);
            } else if(var5 instanceof PolygonFence) {
                PolygonFence var8 = (PolygonFence)var5;
                a(var3, 1, FenceShape.polygon, 0L, var8.getFenceName(), var8.getMonitoredPerson(), (String)null, (LatLng)null, 0.0D, var8.getVertexes(), 0, var8.getCoordType(), var8.getDenoise(), var4);
            } else if(var5 instanceof PolylineFence) {
                PolylineFence var7 = (PolylineFence)var5;
                a(var3, 1, FenceShape.polyline, 0L, var7.getFenceName(), var7.getMonitoredPerson(), (String)null, (LatLng)null, 0.0D, var7.getVertexes(), var7.getOffset(), var7.getCoordType(), var7.getDenoise(), var4);
            } else {
                if(var5 instanceof DistrictFence) {
                    DistrictFence var6 = (DistrictFence)var5;
                    a(var3, 1, FenceShape.district, 0L, var6.getFenceName(), var6.getMonitoredPerson(), var6.getKeyword(), (LatLng)null, 0.0D, (List)null, 0, (CoordType)null, var6.getDenoise(), var4);
                }

            }
        } else {
            com.baidu.trace.c.a.a.execute(new ab(var0, var2, var3, var4, var1));
        }
    }

    protected static void a(Context var0, IService var1, Handler var2, UpdateFenceRequest var3, OnFenceListener var4) {
        if(FenceType.server == var3.getFence().getFenceType()) {
            Fence var5;
            if((var5 = var3.getFence()) instanceof CircleFence) {
                CircleFence var9 = (CircleFence)var5;
                if(FenceType.server == var9.getFenceType()) {
                    a(var3, 2, FenceShape.circle, var9.getFenceId(), var9.getFenceName(), var9.getMonitoredPerson(), (String)null, var9.getCenter(), var9.getRadius(), (List)null, 0, var9.getCoordType(), var9.getDenoise(), var4);
                }

            } else if(var5 instanceof PolygonFence) {
                PolygonFence var8 = (PolygonFence)var5;
                a(var3, 2, FenceShape.polygon, var8.getFenceId(), var8.getFenceName(), var8.getMonitoredPerson(), (String)null, (LatLng)null, 0.0D, var8.getVertexes(), 0, var8.getCoordType(), var8.getDenoise(), var4);
            } else if(var5 instanceof PolylineFence) {
                PolylineFence var7 = (PolylineFence)var5;
                a(var3, 2, FenceShape.polyline, var7.getFenceId(), var7.getFenceName(), var7.getMonitoredPerson(), (String)null, (LatLng)null, 0.0D, var7.getVertexes(), var7.getOffset(), var7.getCoordType(), var7.getDenoise(), var4);
            } else {
                if(var5 instanceof DistrictFence) {
                    DistrictFence var6 = (DistrictFence)var5;
                    a(var3, 2, FenceShape.district, var6.getFenceId(), var6.getFenceName(), var6.getMonitoredPerson(), var6.getKeyword(), (LatLng)null, 0.0D, (List)null, 0, (CoordType)null, var6.getDenoise(), var4);
                }

            }
        } else {
            com.baidu.trace.c.a.a.execute(new ac(var0, var2, var3, var4, var1));
        }
    }

    protected static void a(Context var0, IService var1, Handler var2, DeleteFenceRequest var3, OnFenceListener var4) {
        if(FenceType.server == ((DeleteFenceRequest)var3).getFenceType()) {
            Object var6 = var3;
            TreeMap var7 = new TreeMap();
            if(null != ((DeleteFenceRequest)var3).getFenceIds() && !((DeleteFenceRequest)var3).getFenceIds().isEmpty()) {
                var3 = a(((DeleteFenceRequest)var3).getFenceIds());
                var7.put("fence_ids", var3);
            }

            if(!TextUtils.isEmpty(((DeleteFenceRequest)var3).getMonitoredPerson())) {
                try {
                    var3 = URLEncoder.encode(((DeleteFenceRequest)var6).getMonitoredPerson(), "UTF-8");
                    var7.put("monitored_person", var3);
                } catch (Exception var5) {
                    var7.put("monitored_person", ((DeleteFenceRequest)var3).getMonitoredPerson());
                }
            }

            com.baidu.trace.c.a.a((BaseRequest)var3, 0, "fence/delete", c.b, 3, a(var7, ((DeleteFenceRequest)var3).getServiceId(), c.b), var4);
            var7.clear();
        } else {
            com.baidu.trace.c.a.a.execute(new ad(var0, var2, (DeleteFenceRequest)var3, var4, var1));
        }
    }

    protected static void a(Context var0, Handler var1, FenceListRequest var2, OnFenceListener var3) {
        if(FenceType.server == var2.getFenceType()) {
            FenceListRequest var5 = var2;
            TreeMap var6 = new TreeMap();
            if(!TextUtils.isEmpty(var5.getMonitoredPerson())) {
                try {
                    var3 = URLEncoder.encode(var5.getMonitoredPerson(), "UTF-8");
                    var6.put("monitored_person", var3);
                } catch (Exception var4) {
                    var6.put("monitored_person", var5.getMonitoredPerson());
                }
            }

            if(null != var5.getFenceIds() && !var5.getFenceIds().isEmpty()) {
                var3 = a(var5.getFenceIds());
                var6.put("fence_ids", var3);
            }

            if(null != var5.getCoordTypeOutput()) {
                var6.put("coord_type_output", var5.getCoordTypeOutput().name());
            }

            com.baidu.trace.c.a.a(var5, 0, "fence/list", c.a, 4, a(var6, var5.getServiceId(), c.a), var3);
            var6.clear();
        } else {
            com.baidu.trace.c.a.a.execute(new ae(var0, var1, var2, (OnFenceListener)var3));
        }
    }

    protected static void a(Context var0, Handler var1, MonitoredStatusRequest var2, OnFenceListener var3) {
        if(FenceType.server == var2.getFenceType()) {
            MonitoredStatusRequest var5 = var2;
            TreeMap var6 = new TreeMap();
            if(!TextUtils.isEmpty(var5.getMonitoredPerson())) {
                try {
                    var6.put("monitored_person", URLEncoder.encode(var5.getMonitoredPerson(), "UTF-8"));
                } catch (Exception var4) {
                    var6.put("monitored_person", var5.getMonitoredPerson());
                }
            }

            if(null != var5.getFenceIds() && !var5.getFenceIds().isEmpty()) {
                var3 = a(var5.getFenceIds());
                var6.put("fence_ids", var3);
            }

            com.baidu.trace.c.a.a(var5, 0, "fence/querystatus", c.a, 5, a(var6, var5.getServiceId(), c.a), var3);
            var6.clear();
        } else {
            com.baidu.trace.c.a.a.execute(new af(var0, var1, var2, (OnFenceListener)var3));
        }
    }

    protected static void a(Context var0, Handler var1, MonitoredStatusByLocationRequest var2, OnFenceListener var3) {
        if(FenceType.server == var2.getFenceType()) {
            MonitoredStatusByLocationRequest var5 = var2;
            TreeMap var6 = new TreeMap();
            if(!TextUtils.isEmpty(var5.getMonitoredPerson())) {
                try {
                    var6.put("monitored_person", URLEncoder.encode(var5.getMonitoredPerson(), "UTF-8"));
                } catch (Exception var4) {
                    var6.put("monitored_person", var5.getMonitoredPerson());
                }
            }

            if(null != var5.getFenceIds() && !var5.getFenceIds().isEmpty()) {
                var6.put("fence_ids", a(var5.getFenceIds()));
            }

            if(null != var5.getLatLng()) {
                var6.put("longitude", String.valueOf(var5.getLatLng().longitude));
                var6.put("latitude", String.valueOf(var5.getLatLng().latitude));
            }

            if(null != var5.getCoordType()) {
                var6.put("coord_type", String.valueOf(var5.getCoordType().name()));
            }

            com.baidu.trace.c.a.a(var5, 0, "fence/querystatusbylocation", c.a, 6, a(var6, var5.getServiceId(), c.a), var3);
            var6.clear();
        } else {
            com.baidu.trace.c.a.a.execute(new ag(var0, var1, var2, var3));
        }
    }

    protected static void a(Context var0, Handler var1, HistoryAlarmRequest var2, OnFenceListener var3) {
        if(FenceType.server == var2.getFenceType()) {
            HistoryAlarmRequest var5 = var2;
            TreeMap var6 = new TreeMap();
            if(!TextUtils.isEmpty(var5.getMonitoredPerson())) {
                try {
                    var6.put("monitored_person", URLEncoder.encode(var5.getMonitoredPerson(), "UTF-8"));
                } catch (Exception var4) {
                    var6.put("monitored_person", var5.getMonitoredPerson());
                }
            }

            if(var5.getStartTime() > 0L) {
                var6.put("start_time", String.valueOf(var5.getStartTime()));
            }

            if(var5.getEndTime() > 0L) {
                var6.put("end_time", String.valueOf(var5.getEndTime()));
            }

            if(null != var5.getFenceIds() && !var5.getFenceIds().isEmpty()) {
                var6.put("fence_ids", a(var5.getFenceIds()));
            }

            if(null != var5.getCoordTypeOutput()) {
                var6.put("coord_type_output", var5.getCoordTypeOutput().name());
            }

            com.baidu.trace.c.a.a(var5, 0, "fence/historyalarm", c.a, 7, a(var6, var5.getServiceId(), c.a), var3);
            var6.clear();
        } else {
            com.baidu.trace.c.a.a.execute(new ah(var0, var1, var2, var3));
        }
    }

    private static String b(Context var0, Handler var1, int var2, Fence var3, OnFenceListener var4) {
        CreateFenceResponse var10 = new CreateFenceResponse(var2, 0, "成功", FenceType.local);
        if(var3 == null) {
            var10.setStatus(2);
            var10.setMessage("fence参数错误");
            a(1, var1, var10, var4);
            return null;
        } else {
            CircleFence var11 = (CircleFence)var3;
            var10.setFenceName(var11.getFenceName());
            var10.setFenceShape(FenceShape.circle);
            if(e.a(var11.getCenter())) {
                if(null != var11.getCoordType() && CoordType.bd09ll != var11.getCoordType()) {
                    double[] var5 = null;
                    if(CoordType.wgs84 == var11.getCoordType()) {
                        var5 = TraceJniInterface.wgsToBaidu(var11.getCenter().latitude, var11.getCenter().longitude);
                    } else if(CoordType.gcj02 == var11.getCoordType()) {
                        var5 = TraceJniInterface.gcjToBaidu(var11.getCenter().latitude, var11.getCenter().longitude);
                    }

                    if(var5 == null) {
                        var10.setStatus(2);
                        var10.setMessage("center参数错误");
                        a(1, var1, var10, var4);
                        return null;
                    }

                    LatLng var8 = new LatLng(var5[0], var5[1]);
                    var11.setCenter(var8);
                }

                var11.setCoordType(CoordType.bd09ll);
                if(a((String)var11.getFenceName(), (String)"fenceName", (BaseResponse)var10) && a((String)var11.getMonitoredPerson(), (String)"monitoredPerson", (BaseResponse)var10) && a((double)var11.getDenoise(), "denoise", var10) && a(var11.getRadius(), "radius", var10)) {
                    StringBuffer var12 = new StringBuffer();
                    StringBuffer var13 = new StringBuffer();

                    try {
                        a(var11, var13, var12);
                    } catch (JSONException var9) {
                        var10.setStatus(15001);
                        var10.setMessage("创建本地围栏失败");
                        a(1, var1, var10, var4);
                        return null;
                    }

                    long var6 = am.a(var0, var11.getFenceName(), var11.getMonitoredPerson(), var11.getCoordType(), var11.getDenoise(), FenceShape.circle, var12.toString());
                    if(-1L != var6) {
                        var11.setFenceId(var6);
                        var10.setFenceId(var6);
                        a(1, var1, var10, var4);
                        return var13.toString();
                    } else {
                        var10.setStatus(15001);
                        var10.setMessage("创建本地围栏失败");
                        a(1, var1, var10, var4);
                        return null;
                    }
                } else {
                    a(1, var1, var10, var4);
                    return null;
                }
            } else {
                var10.setStatus(2);
                var10.setMessage("center参数错误");
                a(1, var1, var10, var4);
                return null;
            }
        }
    }

    private static String b(Context var0, Handler var1, UpdateFenceRequest var2, OnFenceListener var3) {
        UpdateFenceResponse var4 = new UpdateFenceResponse(var2.getTag(), 0, "成功", FenceType.local);
        if(null == var2.getFence()) {
            var4.setStatus(2);
            var4.setMessage("fence参数错误");
            a(2, var1, var4, var3);
            return null;
        } else {
            long var5 = var2.getFence().getFenceId();
            CircleFence var7 = am.a(var0, var5);
            if(var7 == null) {
                var4.setStatus(15000);
                var4.setMessage("指定fenceId不存在");
                a(2, var1, var4, var3);
                return null;
            } else {
                CircleFence var11;
                if(!TextUtils.isEmpty((var11 = (CircleFence)var2.getFence()).getFenceName())) {
                    if(!a((String)var11.getFenceName(), (String)"fenceName", (BaseResponse)var4)) {
                        a(2, var1, var4, var3);
                        return null;
                    }

                    var7.setFenceName(var11.getFenceName());
                }

                if(!TextUtils.isEmpty(var11.getMonitoredPerson())) {
                    if(!a((String)var11.getMonitoredPerson(), (String)"monitoredPerson", (BaseResponse)var4)) {
                        a(2, var1, var4, var3);
                        return null;
                    }

                    var7.setMonitoredPerson(var11.getMonitoredPerson());
                }

                if(e.a(var11.getCenter())) {
                    if(null != var11.getCoordType() && CoordType.bd09ll != var11.getCoordType()) {
                        double[] var8 = null;
                        if(CoordType.wgs84 == var11.getCoordType()) {
                            var8 = TraceJniInterface.wgsToBaidu(var11.getCenter().latitude, var11.getCenter().longitude);
                        } else if(CoordType.gcj02 == var11.getCoordType()) {
                            var8 = TraceJniInterface.gcjToBaidu(var11.getCenter().latitude, var11.getCenter().longitude);
                        }

                        if(var8 == null) {
                            var4.setStatus(2);
                            var4.setMessage("center参数错误");
                            a(2, var1, var4, var3);
                            return null;
                        }

                        LatLng var9 = new LatLng(var8[0], var8[1]);
                        var7.setCenter(var9);
                    } else {
                        var7.setCenter(var11.getCenter());
                    }

                    var7.setCoordType(CoordType.bd09ll);
                }

                if(a((double)var11.getDenoise(), "denoise", var4) && a(var11.getRadius(), "radius", var4)) {
                    if(var11.getDenoise() > 0) {
                        var7.setDenoise(var11.getDenoise());
                    }

                    if(var11.getRadius() > 0.0D) {
                        var7.setRadius(var11.getRadius());
                    }

                    StringBuffer var12 = new StringBuffer();
                    StringBuffer var13 = new StringBuffer();

                    try {
                        a(var7, var13, var12);
                    } catch (JSONException var10) {
                        var4.setStatus(15002);
                        var4.setMessage("更新本地围栏失败");
                        var4.setFenceId(var5);
                        a(2, var1, var4, var3);
                        return null;
                    }

                    if(am.a(var0, var5, var7.getFenceName(), var7.getMonitoredPerson(), var7.getCoordType(), var7.getDenoise(), FenceShape.circle, var12.toString())) {
                        var4.setFenceName(var7.getFenceName());
                        var4.setFenceId(var5);
                        a(2, var1, var4, var3);
                        return var13.toString();
                    } else {
                        var4.setStatus(15002);
                        var4.setMessage("更新本地围栏失败");
                        a(2, var1, var4, var3);
                        return null;
                    }
                } else {
                    a(2, var1, var4, var3);
                    return null;
                }
            }
        }
    }

    private static void a(BaseRequest var0, int var1, FenceShape var2, long var3, String var5, String var6, String var7, LatLng var8, double var9, List<LatLng> var11, int var12, CoordType var13, int var14, OnFenceListener var15) {
        TreeMap var16 = new TreeMap();
        long var10000 = var3;
        String var10001 = var5;
        String var10003 = var7;
        List var10006 = var11;
        TreeMap var31 = var16;
        List var30 = var10006;
        var5 = var10003;
        String var4 = var6;
        String var29 = var10001;
        long var18 = var10000;
        if(var10000 > 0L) {
            var16.put("fence_id", String.valueOf(var18));
        }

        if(!TextUtils.isEmpty(var29)) {
            try {
                var31.put("fence_name", URLEncoder.encode(var29, "UTF-8"));
            } catch (Exception var28) {
                var16.put("fence_name", var29);
            }
        }

        if(!TextUtils.isEmpty(var6)) {
            try {
                var31.put("monitored_person", URLEncoder.encode(var4, "UTF-8"));
            } catch (Exception var27) {
                var16.put("monitored_person", var6);
            }
        }

        if(var8 != null) {
            var16.put("longitude", String.valueOf(var8.longitude));
            var16.put("latitude", String.valueOf(var8.latitude));
        }

        if(var9 > 0.0D) {
            var16.put("radius", String.valueOf(var9));
        }

        if(var30 != null) {
            var16.put("vertexes", String.valueOf(b(var30)));
        }

        if(var12 > 0) {
            var16.put("offset", String.valueOf(var12));
        }

        if(var13 != null) {
            var16.put("coord_type", var13.name());
        }

        if(var14 >= 0) {
            var16.put("denoise", String.valueOf(var14));
        }

        if(!TextUtils.isEmpty(var5)) {
            try {
                var31.put("keyword", URLEncoder.encode(var5, "UTF-8"));
            } catch (Exception var26) {
                var16.put("keyword", var5);
            }
        }

        var29 = "";
        if(1 == var1) {
            if(FenceShape.circle == var2) {
                var29 = "createcirclefence";
            } else if(FenceShape.polygon == var2) {
                var29 = "createpolygonfence";
            } else if(FenceShape.polyline == var2) {
                var29 = "createpolylinefence";
            } else if(FenceShape.district == var2) {
                var29 = "createdistrictfence";
            }
        } else if(2 == var1) {
            if(FenceShape.circle == var2) {
                var29 = "updatecirclefence";
            } else if(FenceShape.polygon == var2) {
                var29 = "updatepolygonfence";
            } else if(FenceShape.polyline == var2) {
                var29 = "updatepolylinefence";
            } else if(FenceShape.district == var2) {
                var29 = "updatedistrictfence";
            }
        }

        if(!var16.isEmpty()) {
            com.baidu.trace.c.a.a(var0, 0, "fence/" + var29, c.b, var1, a(var16, var0.getServiceId(), c.b), var15);
        }

        var16.clear();
    }

    protected static String a(List<Long> var0) {
        StringBuffer var1 = new StringBuffer();
        Iterator var3 = var0.iterator();

        while(var3.hasNext()) {
            Long var2 = (Long)var3.next();
            if(var2 != null) {
                var1.append(var2).append(",");
            }
        }

        if(TextUtils.isEmpty(var1.toString())) {
            return "";
        } else {
            return var1.substring(0, var1.length() - 1);
        }
    }

    protected static boolean a(String var0, String var1, BaseResponse var2) {
        if(e.a(var0)) {
            return true;
        } else {
            var2.setStatus(2);
            var2.setMessage(var1 + "参数错误");
            return false;
        }
    }

    protected static boolean a(double var0, String var2, BaseResponse var3) {
        if(var0 < 0.0D) {
            var3.setStatus(2);
            var3.setMessage(var2 + "参数错误");
            return false;
        } else {
            return true;
        }
    }

    protected static String b(List<LatLng> var0) {
        StringBuffer var1 = new StringBuffer();
        Iterator var3 = var0.iterator();

        while(var3.hasNext()) {
            LatLng var2 = (LatLng)var3.next();
            var1.append(var2.latitude).append(",").append(var2.longitude).append(";");
        }

        return TextUtils.isEmpty(var1.toString())?"":var1.substring(0, var1.length() - 1);
    }

    protected static void a(Fence var0, String var1, LatLng var2, List<MonitoredStatusInfo> var3) {
        if(var0 instanceof CircleFence) {
            CircleFence var4 = (CircleFence)var0;
            long var5 = var0.getFenceId();
            if(var4.getMonitoredPerson().equals(var1)) {
                MonitoredStatusInfo var11 = new MonitoredStatusInfo();
                double var9 = e.a(var4.getCenter(), var2);
                if(var4.getRadius() > var9) {
                    var11.setMonitoredStatus(MonitoredStatus.in);
                } else {
                    var11.setMonitoredStatus(MonitoredStatus.out);
                }

                var11.setFenceId(var5);
                var3.add(var11);
            }
        }

    }

    protected static void a(CircleFence var0, StringBuffer var1, StringBuffer var2) throws JSONException {
        JSONObject var3;
        (var3 = new JSONObject()).put("latitude", var0.getCenter().latitude);
        var3.put("longitude", var0.getCenter().longitude);
        JSONObject var4;
        if(var2 != null) {
            (var4 = new JSONObject()).put("radius", var0.getRadius());
            var4.put("center", var3);
            var2.append(var4.toString());
        }

        if(var1 != null) {
            (var4 = new JSONObject()).put("fenceName", var0.getFenceName());
            var4.put("monitoredPerson", var0.getMonitoredPerson());
            var4.put("coordType", var0.getCoordType());
            var4.put("denoise", var0.getDenoise());
            var4.put("fenceShape", CircleFence.class.getSimpleName());
            var4.put("radius", var0.getRadius());
            var4.put("center", var3);
            var1.append(var4.toString());
        }

    }

    protected static void a(JSONObject var0, CircleFence var1) throws JSONException {
        if(var0.has("fenceName")) {
            var1.setFenceName(var0.getString("fenceName"));
        }

        if(var0.has("monitoredPerson")) {
            var1.setMonitoredPerson(var0.getString("monitoredPerson"));
        }

        if(var0.has("denoise")) {
            var1.setDenoise(var0.getInt("denoise"));
        }

        if(var0.has("radius")) {
            var1.setRadius(var0.getDouble("radius"));
        }

        if(var0.has("center")) {
            var0 = var0.getJSONObject("center");
            LatLng var2 = new LatLng();
            if(var0.has("latitude")) {
                var2.latitude = var0.getDouble("latitude");
                var2.longitude = var0.getDouble("longitude");
            }

            var1.setCenter(var2);
        }

    }

    public static void a(BaseRequest var0, int var1, boolean var2, int var3, String var4, OnFenceListener var5) {
        int var6 = var0.getTag();
        FenceShape var7 = FenceShape.circle;
        String var15;
        switch(var1) {
            case 1:
                Fence var20;
                if((var20 = ((CreateFenceRequest)var0).getFence()) instanceof PolygonFence) {
                    var7 = FenceShape.polygon;
                } else if(var20 instanceof PolylineFence) {
                    var7 = FenceShape.polyline;
                } else if(var20 instanceof DistrictFence) {
                    var7 = FenceShape.district;
                }

                var15 = var20.getFenceName();
                CreateFenceResponse var23 = new CreateFenceResponse(var6, var3, var4, var15, var7, FenceType.server);
                if(var2) {
                    CreateFenceResponse var21 = var23;
                    String var22 = var4;

                    try {
                        JSONObject var25 = new JSONObject(var22);
                        if(b(var22, var21)) {
                            if(var25.has("fence_id")) {
                                var21.setFenceId(var25.getLong("fence_id"));
                            }

                            if(var25.has("fence_name")) {
                                var21.setFenceName(var25.getString("fence_name"));
                            }

                            if(var25.has("shape")) {
                                var21.setFenceShape((FenceShape)FenceShape.valueOf(FenceShape.class, var25.getString("shape")));
                            }

                            if(var25.has("district")) {
                                var21.setDistrict(var25.getString("district"));
                            }

                            if(var25.has("district_list")) {
                                JSONArray var24;
                                var3 = (var24 = var25.getJSONArray("district_list")).length();
                                ArrayList var26 = new ArrayList();

                                for(var6 = 0; var6 < var3; ++var6) {
                                    var26.add(var24.getString(var6));
                                }

                                var21.setDistrictList(var26);
                            }
                        }
                    } catch (Exception var10) {
                        ;
                    } finally {
                        ;
                    }
                }

                var5.onCreateFenceCallback(var23);
                return;
            case 2:
                Fence var19;
                var15 = (var19 = ((UpdateFenceRequest)var0).getFence()).getFenceName();
                UpdateFenceResponse var17 = new UpdateFenceResponse(var6, var3, var4, var19.getFenceId(), var15, FenceType.server);
                var7 = FenceShape.circle;
                if(var19 instanceof CircleFence) {
                    var7 = FenceShape.circle;
                } else if(var19 instanceof PolygonFence) {
                    var7 = FenceShape.polygon;
                } else if(var19 instanceof PolylineFence) {
                    var7 = FenceShape.polyline;
                } else if(var19 instanceof DistrictFence) {
                    var7 = FenceShape.district;
                }

                var17.setFenceShape(var7);
                if(var2) {
                    a(var4, var17);
                }

                var5.onUpdateFenceCallback(var17);
                return;
            case 3:
                DeleteFenceResponse var14 = new DeleteFenceResponse(var6, var3, var4, FenceType.server);
                if(var2) {
                    a(var4, var14);
                }

                var5.onDeleteFenceCallback(var14);
                return;
            case 4:
                FenceListResponse var18 = new FenceListResponse(var6, var3, var4, FenceType.server);
                if(var2) {
                    a(var4, ((FenceListRequest)var0).getCoordTypeOutput(), var18);
                }

                var5.onFenceListCallback(var18);
                return;
            case 5:
                MonitoredStatusResponse var13 = new MonitoredStatusResponse(var6, var3, var4, FenceType.server);
                if(var2) {
                    a((String)var4, (BaseResponse)var13);
                }

                var5.onMonitoredStatusCallback(var13);
                return;
            case 6:
                MonitoredStatusByLocationResponse var12 = new MonitoredStatusByLocationResponse(var6, var3, var4, FenceType.server);
                if(var2) {
                    a((String)var4, (BaseResponse)var12);
                }

                var5.onMonitoredStatusByLocationCallback(var12);
                return;
            case 7:
                HistoryAlarmResponse var16 = new HistoryAlarmResponse(var6, var3, var4, FenceType.server);
                if(var2) {
                    a(var4, ((HistoryAlarmRequest)var0).getCoordTypeOutput(), var16);
                }

                var5.onHistoryAlarmCallback(var16);
            default:
        }
    }

    protected static void a(int var0, Handler var1, BaseResponse var2, OnFenceListener var3) {
        var1.post(new ai(var0, var3, var2));
    }

    protected static boolean a(String var0, BaseRequest var1, Object var2) {
        if(var1 == null) {
            a("BaiduTraceSDK", var0 + ", request object is null!");
            return false;
        } else if(var2 == null) {
            a("BaiduTraceSDK", var0 + ", listener is null!");
            return false;
        } else {
            return true;
        }
    }

    protected static void b(String var0) {
        try {
            JSONObject var2;
            if((var2 = new JSONObject(var0)).has("status") && var2.getInt("status") == 0) {
                d.a = URLEncoder.encode(var2.getString("token"), "UTF-8");
            }

        } catch (Exception var1) {
            ;
        }
    }

    protected static void a(ProcessOption var0, TreeMap<String, String> var1) {
        StringBuffer var2 = new StringBuffer("");
        if(var0 != null && var0.isNeedDenoise()) {
            var2.append("need_denoise=").append(1);
        } else {
            var2.append("need_denoise=").append(0);
        }

        if(var0 != null && var0.isNeedVacuate()) {
            var2.append(",need_vacuate").append("=1");
        } else {
            var2.append(",need_vacuate").append("=0");
        }

        if(var0 != null && var0.isNeedMapMatch()) {
            var2.append(",need_mapmatch").append("=1");
        } else {
            var2.append(",need_mapmatch").append("=0");
        }

        if(var0 != null && var0.getRadiusThreshold() > 0) {
            var2.append(",radius_threshold").append("=").append(var0.getRadiusThreshold());
        }

        if(var0 != null && null != var0.getTransportMode()) {
            var2.append(",transport_mode").append("=").append(var0.getTransportMode().name());
        }

        if(var2.length() > 0 && var2.charAt(0) == 44) {
            var2.replace(0, 1, "");
        }

        if(!TextUtils.isEmpty(var2.toString())) {
            var1.put("process_option", var2.toString());
        }

    }

    protected static String a(TreeMap<String, String> var0, long var1, c var3) {
        StringBuffer var4 = new StringBuffer();
        var0.put("service_id", String.valueOf(var1));
        var0.put("os", q.a);
        var0.put("sdk_version", q.b);
        var0.put("pcn", q.d);
        var0.put("token", d.a);

        try {
            var0.put("cuid", URLEncoder.encode(q.c, "UTF-8"));
        } catch (Exception var7) {
            ;
        }

        try {
            String var9 = a(var0);
            String var2 = new String(var9 + "99754106633f94d350db34d548d6091a");
            byte[] var10 = MessageDigest.getInstance("MD5").digest(var2.getBytes());
            StringBuffer var5 = new StringBuffer();

            for(int var6 = 0; var6 < var10.length; ++var6) {
                var5.append(Integer.toHexString(var10[var6] & 255 | 256).substring(1, 3));
            }

            if(c.b == var3) {
                var9 = b(var0);
            }

            var4.append(var9).append("&sign").append("=").append(var5.toString());
        } catch (Exception var8) {
            ;
        }

        return var4.toString();
    }

    protected static String a(TreeMap<String, String> var0) throws UnsupportedEncodingException {
        StringBuffer var1 = new StringBuffer();
        Iterator var3 = var0.entrySet().iterator();

        while(var3.hasNext()) {
            Entry var2 = (Entry)var3.next();
            var1.append((String)var2.getKey()).append("=").append((String)var2.getValue()).append("&");
        }

        if(var1.length() > 0) {
            var1.deleteCharAt(var1.length() - 1);
        }

        return var1.toString();
    }

    protected static String b(TreeMap<String, String> var0) throws UnsupportedEncodingException {
        StringBuffer var1 = new StringBuffer();
        Iterator var4 = var0.entrySet().iterator();

        while(var4.hasNext()) {
            Entry var2;
            String var3;
            if(!TextUtils.isEmpty(var3 = (String)(var2 = (Entry)var4.next()).getValue())) {
                if(var3.contains("%")) {
                    var1.append((String)var2.getKey()).append("=").append(URLEncoder.encode(var3, "UTF-8")).append("&");
                } else {
                    var1.append((String)var2.getKey()).append("=").append(var3).append("&");
                }
            }
        }

        if(var1.length() > 0) {
            var1.deleteCharAt(var1.length() - 1);
        }

        return var1.toString();
    }

    public static void a(String var0, CoordType var1, LatestPointResponse var2) {
        var1 = var1 != null?var1:CoordType.bd09ll;

        try {
            if(b(var0, var2)) {
                JSONObject var10 = new JSONObject(var0);
                LatestPoint var11 = new LatestPoint((LatLng)null, var1);
                if(var10.has("latest_point")) {
                    JSONObject var3;
                    Iterator var4 = (var3 = var10.getJSONObject("latest_point")).keys();
                    ArrayList var5 = new ArrayList();

                    while(var4.hasNext()) {
                        var5.add(var4.next());
                    }

                    a((JSONObject)var3, (Point)var11, (List)var5);
                    var2.setLatestPoint(var11);
                }

                if(var10.has("limit_speed")) {
                    var2.setLimitSpeed(var10.getDouble("limit_speed"));
                }

            }
        } catch (Exception var8) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, AddPointsResponse var1) {
        try {
            if(b(var0, var1)) {
                JSONObject var11;
                if((var11 = new JSONObject(var0)).has("success_num")) {
                    var1.setSuccessNum(var11.getInt("success_num"));
                }

                FailInfo var2 = new FailInfo();
                if(var11.has("fail_info")) {
                    var11 = var11.getJSONObject("fail_info");
                    ArrayList var3 = new ArrayList();
                    if(var11.has("param_error")) {
                        JSONArray var4 = var11.getJSONArray("param_error");

                        for(int var5 = 0; var5 < var4.length(); ++var5) {
                            var2.getClass();
                            ParamError var6 = new ParamError(var2);
                            a((JSONObject)var4.getJSONObject(var5), (InternalError)var6);
                            var3.add(var6);
                        }
                    }

                    var2.setParamErrors(var3);
                    ArrayList var13 = new ArrayList();
                    if(var11.has("internal_error")) {
                        JSONArray var14 = var11.getJSONArray("internal_error");

                        for(int var15 = 0; var15 < var14.length(); ++var15) {
                            var2.getClass();
                            InternalError var12 = new InternalError(var2);
                            a(var14.getJSONObject(var15), var12);
                            var13.add(var12);
                        }
                    }

                    var2.setInternalErrors(var13);
                }

                var1.setFailInfo(var2);
            }
        } catch (Exception var9) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, CoordType var1, CommonResponse var2) {
        var1 = var1 != null?var1:CoordType.bd09ll;

        try {
            if(b(var0, var2)) {
                JSONObject var17;
                if((var17 = new JSONObject(var0)).has("total")) {
                    var2.setTotal(var17.getInt("total"));
                }

                if(var17.has("size")) {
                    var2.setSize(var17.getInt("size"));
                }

                ArrayList var3 = new ArrayList();
                JSONArray var4;
                int var5;
                if(var17.has("entities")) {
                    var5 = (var4 = var17.getJSONArray("entities")).length();

                    for(int var6 = 0; var6 < var5; ++var6) {
                        EntityInfo var7 = new EntityInfo();
                        JSONObject var8;
                        Iterator var9 = (var8 = var4.getJSONObject(var6)).keys();
                        ArrayList var10 = new ArrayList();

                        while(var9.hasNext()) {
                            var10.add(var9.next());
                        }

                        if(var8.has("entity_name")) {
                            var7.setEntityName(var8.getString("entity_name"));
                            var10.remove("entity_name");
                        }

                        if(var8.has("entity_desc")) {
                            var7.setEntityDesc(var8.getString("entity_desc"));
                            var10.remove("entity_desc");
                        }

                        if(var8.has("create_time")) {
                            var7.setCreateTime(var8.getString("create_time"));
                            var10.remove("create_time");
                        }

                        if(var8.has("modify_time")) {
                            var7.setModifyTime(var8.getString("modify_time"));
                            var10.remove("modify_time");
                        }

                        Iterator var11;
                        if(var8.has("latest_location")) {
                            JSONObject var20 = var8.getJSONObject("latest_location");
                            var10.remove("latest_location");
                            var11 = var20.keys();
                            ArrayList var12 = new ArrayList();

                            while(var11.hasNext()) {
                                var12.add(var11.next());
                            }

                            LatestLocation var22 = new LatestLocation(var1);
                            a((JSONObject)var20, (Point)var22, (List)var12);
                            var7.setLatestLocation(var22);
                        }

                        HashMap var21 = new HashMap();
                        var11 = var10.iterator();

                        while(var11.hasNext()) {
                            String var23 = (String)var11.next();
                            var21.put(var23, var8.getString(var23));
                        }

                        var7.setColumns(var21);
                        var3.add(var7);
                    }
                }

                if(var2 instanceof DistrictSearchResponse && var17.has("district_list")) {
                    var5 = (var4 = var17.getJSONArray("district_list")).length();
                    ArrayList var18 = new ArrayList();

                    for(int var19 = 0; var19 < var5; ++var19) {
                        var18.add(var4.getString(var19));
                    }

                    ((DistrictSearchResponse)var2).setDistrictList(var18);
                }

                var2.setEntities(var3);
            }
        } catch (Exception var15) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, UpdateFenceResponse var1) {
        try {
            JSONObject var2 = new JSONObject(var0);
            if(b(var0, var1)) {
                if(var2.has("district")) {
                    var1.setDistrict(var2.getString("district"));
                }

                if(var2.has("district_list")) {
                    JSONArray var9;
                    int var10 = (var9 = var2.getJSONArray("district_list")).length();
                    ArrayList var3 = new ArrayList();

                    for(int var4 = 0; var4 < var10; ++var4) {
                        var3.add(var9.getString(var4));
                    }

                    var1.setDistrictList(var3);
                }

            }
        } catch (JSONException var7) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, DeleteFenceResponse var1) {
        try {
            JSONObject var2 = new JSONObject(var0);
            if(b(var0, var1)) {
                ArrayList var9 = new ArrayList();
                if(var2.has("fence_ids")) {
                    JSONArray var10;
                    int var3 = (var10 = var2.getJSONArray("fence_ids")).length();

                    for(int var4 = 0; var4 < var3; ++var4) {
                        var9.add(Long.valueOf(var10.getLong(var4)));
                    }
                }

                var1.setFenceIds(var9);
            }
        } catch (Exception var7) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, CoordType var1, FenceListResponse var2) {
        try {
            JSONObject var3 = new JSONObject(var0);
            if(b(var0, var2)) {
                if(var3.has("size")) {
                    var2.setSize(var3.getInt("size"));
                }

                ArrayList var25 = new ArrayList();
                if(var3.has("fences")) {
                    JSONArray var26;
                    int var4 = (var26 = var3.getJSONArray("fences")).length();

                    for(int var5 = 0; var5 < var4; ++var5) {
                        FenceInfo var6 = new FenceInfo();
                        JSONObject var7 = var26.getJSONObject(var5);
                        long var10 = 0L;
                        if(var7.has("fence_id")) {
                            var10 = var7.getLong("fence_id");
                        }

                        if(var7.has("create_time")) {
                            var6.setCreateTime(var7.getString("create_time"));
                        }

                        if(var7.has("modify_time")) {
                            var6.setModifyTime(var7.getString("modify_time"));
                        }

                        if(var7.has("shape")) {
                            var6.setFenceShape((FenceShape)FenceShape.valueOf(FenceShape.class, var7.getString("shape")));
                        }

                        String var8 = "";
                        if(var7.has("fence_name")) {
                            var8 = var7.getString("fence_name");
                        }

                        String var9 = "";
                        if(var7.has("monitored_person")) {
                            var9 = var7.getString("monitored_person");
                        }

                        LatLng var12 = null;
                        if(var7.has("longitude") && var7.has("latitude")) {
                            var12 = new LatLng(var7.getDouble("latitude"), var7.getDouble("longitude"));
                        }

                        double var15 = 0.0D;
                        if(var7.has("radius")) {
                            var15 = var7.getDouble("radius");
                        }

                        ArrayList var13 = null;
                        int var17;
                        int var18;
                        if(var7.has("vertexes")) {
                            var13 = new ArrayList();
                            JSONArray var14;
                            var17 = (var14 = var7.getJSONArray("vertexes")).length();

                            for(var18 = 0; var18 < var17; ++var18) {
                                JSONObject var19 = var14.getJSONObject(var18);
                                LatLng var20 = new LatLng(var19.getDouble("latitude"), var19.getDouble("longitude"));
                                var13.add(var20);
                            }
                        }

                        CoordType var27 = var1 != null?var1:CoordType.bd09ll;
                        if(var7.has("coord_type")) {
                            var27 = CoordType.valueOf(var7.getString("coord_type"));
                        }

                        var17 = 0;
                        if(var7.has("offset")) {
                            var17 = var7.getInt("offset");
                        }

                        var18 = 0;
                        if(var7.has("denoise")) {
                            var18 = var7.getInt("denoise");
                        }

                        String var28 = "";
                        if(var7.has("district")) {
                            var28 = var7.getString("district");
                        }

                        if(var6.getFenceShape() == FenceShape.circle) {
                            CircleFence var29 = CircleFence.buildServerFence(var10, var8, var9, var12, var15, var18, var27);
                            var6.setCircleFence(var29);
                        } else if(var6.getFenceShape() == FenceShape.polygon) {
                            PolygonFence var30 = PolygonFence.buildServerFence(var10, var8, var9, var13, var18, var27);
                            var6.setPolygonFence(var30);
                        } else if(var6.getFenceShape() == FenceShape.polyline) {
                            PolylineFence var31 = PolylineFence.buildServerFence(var10, var8, var9, var13, var17, var18, var27);
                            var6.setPolylineFence(var31);
                        } else if(var6.getFenceShape() == FenceShape.district) {
                            DistrictFence var32;
                            (var32 = DistrictFence.buildServerFence(var10, var8, var9, var18, (String)null)).setDistrict(var28);
                            var6.setDistrictFence(var32);
                        }

                        var25.add(var6);
                    }
                }

                var2.setFenceInfos(var25);
            }
        } catch (Exception var23) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, BaseResponse var1) {
        try {
            JSONObject var2 = new JSONObject(var0);
            if(b(var0, var1)) {
                if(var2.has("size")) {
                    if(var1 instanceof MonitoredStatusResponse) {
                        ((MonitoredStatusResponse)var1).setSize(var2.getInt("size"));
                    } else if(var1 instanceof MonitoredStatusByLocationResponse) {
                        ((MonitoredStatusByLocationResponse)var1).setSize(var2.getInt("size"));
                    }
                }

                ArrayList var11 = new ArrayList();
                if(var2.has("monitored_statuses")) {
                    JSONArray var12;
                    int var3 = (var12 = var2.getJSONArray("monitored_statuses")).length();

                    for(int var4 = 0; var4 < var3; ++var4) {
                        MonitoredStatusInfo var5 = new MonitoredStatusInfo();
                        JSONObject var6;
                        if((var6 = var12.getJSONObject(var4)).has("fence_id")) {
                            var5.setFenceId(var6.getLong("fence_id"));
                        }

                        if(var6.has("monitored_status")) {
                            var5.setMonitoredStatus((MonitoredStatus)MonitoredStatus.valueOf(MonitoredStatus.class, var6.getString("monitored_status")));
                        }

                        var11.add(var5);
                    }
                }

                if(var1 instanceof MonitoredStatusResponse) {
                    ((MonitoredStatusResponse)var1).setMonitoredStatusInfos(var11);
                } else {
                    if(var1 instanceof MonitoredStatusByLocationResponse) {
                        ((MonitoredStatusByLocationResponse)var1).setMonitoredStatusInfos(var11);
                    }

                }
            }
        } catch (Exception var9) {
            ;
        } finally {
            ;
        }
    }

    public static void a(String var0, CoordType var1, HistoryAlarmResponse var2) {
        var1 = var1 != null?var1:CoordType.bd09ll;

        try {
            JSONObject var3 = new JSONObject(var0);
            if(b(var0, var2)) {
                if(var3.has("size")) {
                    var2.setSize(var3.getInt("size"));
                }

                if(var3.has("total")) {
                    var2.setTotal(var3.getInt("total"));
                }

                ArrayList var13 = new ArrayList();
                if(var3.has("alarms")) {
                    JSONArray var14;
                    int var4 = (var14 = var3.getJSONArray("alarms")).length();

                    for(int var5 = 0; var5 < var4; ++var5) {
                        FenceAlarmInfo var6 = new FenceAlarmInfo();
                        JSONObject var7;
                        if((var7 = var14.getJSONObject(var5)).has("fence_id")) {
                            var6.setFenceId(var7.getLong("fence_id"));
                        }

                        if(var7.has("fence_name")) {
                            var6.setFenceName(var7.getString("fence_name"));
                        }

                        if(var7.has("monitored_person")) {
                            var6.setMonitoredPerson(var7.getString("monitored_person"));
                        }

                        if(var7.has("action")) {
                            var6.setMonitoredAction((MonitoredAction)MonitoredAction.valueOf(MonitoredAction.class, var7.getString("action")));
                        }

                        AlarmPoint var8;
                        if(var7.has("alarm_point")) {
                            var8 = new AlarmPoint();
                            a(var7.getJSONObject("alarm_point"), var1, var8, String.class);
                            var6.setCurrentPoint(var8);
                        }

                        if(var7.has("pre_point")) {
                            var8 = new AlarmPoint();
                            a(var7.getJSONObject("pre_point"), var1, var8, String.class);
                            var6.setPrePoint(var8);
                        }

                        var13.add(var6);
                    }
                }

                var2.setFenceAlarmInfos(var13);
            }
        } catch (Exception var11) {
            ;
        } finally {
            ;
        }
    }

    public static void a(JSONObject var0, CoordType var1, AlarmPoint var2, Class var3) throws JSONException {
        if(var0.has("loc_time")) {
            var2.setLocTime(var0.getLong("loc_time"));
        } else if(var0.has("time")) {
            var2.setLocTime(var0.getLong("time"));
        }

        if(var0.has("create_time")) {
            var2.setCreateTime(var0.getLong("create_time"));
        }

        if(var0.has("longitude") && var0.has("latitude")) {
            var2.setLocation(new LatLng(var0.getDouble("latitude"), var0.getDouble("longitude")));
        }

        if(var0.has("radius")) {
            var2.setRadius(var0.getDouble("radius"));
        }

        var1 = var1 != null?var1:CoordType.bd09ll;
        if(var0.has("coord_type")) {
            if(String.class.isAssignableFrom(var3)) {
                var1 = CoordType.valueOf(var0.getString("coord_type"));
            } else if(Integer.class.isAssignableFrom(var3)) {
                switch(var0.getInt("coord_type")) {
                    case 1:
                        var1 = CoordType.wgs84;
                        break;
                    case 2:
                        var1 = CoordType.gcj02;
                        break;
                    case 3:
                        var1 = CoordType.bd09ll;
                        break;
                    default:
                        var1 = CoordType.bd09ll;
                }
            }
        }

        var2.setCoordType(var1);
    }

    public static void a(String var0, CoordType var1, DrivingBehaviorResponse var2) {
        var1 = var1 != null?var1:CoordType.bd09ll;

        try {
            JSONObject var3 = new JSONObject(var0);
            if(b(var0, var2)) {
                if(var3.has("distance")) {
                    var2.setDistance(var3.getDouble("distance"));
                }

                if(var3.has("duration")) {
                    var2.setDuration(var3.getInt("duration"));
                }

                if(var3.has("average_speed")) {
                    var2.setAverageSpeed(var3.getDouble("average_speed"));
                }

                if(var3.has("max_speed")) {
                    var2.setMaxSpeed(var3.getDouble("max_speed"));
                }

                if(var3.has("speeding_num")) {
                    var2.setSpeedingNum(var3.getInt("speeding_num"));
                }

                if(var3.has("harsh_acceleration_num")) {
                    var2.setHarshAccelerationNum(var3.getInt("harsh_acceleration_num"));
                }

                if(var3.has("harsh_breaking_num")) {
                    var2.setHarshBreakingNum(var3.getInt("harsh_breaking_num"));
                }

                if(var3.has("harsh_steering_num")) {
                    var2.setHarshSteeringNum(var3.getInt("harsh_steering_num"));
                }

                JSONObject var23;
                if(var3.has("start_point")) {
                    var23 = var3.getJSONObject("start_point");
                    StartPoint var4 = new StartPoint(var1);
                    a((JSONObject)var23, (Point)var4, (List)null);
                    var2.setStartPoint(var4);
                }

                if(var3.has("end_point")) {
                    var23 = var3.getJSONObject("end_point");
                    EndPoint var25 = new EndPoint(var1);
                    a((JSONObject)var23, (Point)var25, (List)null);
                    var2.setEndPoint(var25);
                }

                String[] var24 = new String[]{"speeding", "harsh_acceleration", "harsh_breaking", "harsh_steering"};
                int var26 = 0;
                ArrayList var5 = new ArrayList();
                ArrayList var6 = new ArrayList();
                ArrayList var7 = new ArrayList();

                ArrayList var8;
                for(var8 = new ArrayList(); var26 < var24.length && var3.has(var24[var26]); ++var26) {
                    JSONArray var9;
                    int var10 = (var9 = var3.getJSONArray(var24[var26])).length();

                    for(int var11 = 0; var11 < var10; ++var11) {
                        JSONObject var12;
                        if("speeding".equals(var24[var26])) {
                            JSONObject var29 = var9.getJSONObject(var11);
                            SpeedingInfo var14 = new SpeedingInfo();
                            if(var29.has("speeding_distance")) {
                                var14.setDistance(var29.getDouble("speeding_distance"));
                            }

                            if(var29.has("speeding_points")) {
                                JSONArray var30 = var29.getJSONArray("speeding_points");
                                ArrayList var15 = new ArrayList();
                                int var16 = var30.length();

                                for(int var17 = 0; var17 < var16; ++var17) {
                                    SpeedingPoint var18 = new SpeedingPoint(var1);
                                    a((JSONObject)(var12 = var30.getJSONObject(var17)), (Point)var18, (List)null);
                                    a((JSONObject)var12, (Point)var18);
                                    var15.add(var18);
                                }

                                var14.setPoints(var15);
                            }

                            var5.add(var14);
                        } else if("harsh_acceleration".equals(var24[var26])) {
                            HarshAccelerationPoint var13 = new HarshAccelerationPoint(var1);
                            a((JSONObject)(var12 = var9.getJSONObject(var11)), (Point)var13, (List)null);
                            a((JSONObject)var12, (Point)var13);
                            var6.add(var13);
                        } else if("harsh_breaking".equals(var24[var26])) {
                            HarshBreakingPoint var27 = new HarshBreakingPoint(var1);
                            a((JSONObject)(var12 = var9.getJSONObject(var11)), (Point)var27, (List)null);
                            a((JSONObject)var12, (Point)var27);
                            var7.add(var27);
                        } else if("harsh_steering".equals(var24[var26])) {
                            HarshSteeringPoint var28 = new HarshSteeringPoint(var1);
                            a((JSONObject)(var12 = var9.getJSONObject(var11)), (Point)var28, (List)null);
                            a((JSONObject)var12, (Point)var28);
                            var8.add(var28);
                        }
                    }
                }

                var2.setSpeedings(var5);
                var2.setHarshAccelerationPoints(var6);
                var2.setHarshBreakingPoints(var7);
                var2.setHarshSteeringPoints(var8);
            }
        } catch (Exception var21) {
            ;
        } finally {
            ;
        }
    }

    public static void a(JSONObject var0, Point var1) throws JSONException {
        if(var0.has("actual_speed") && var1 instanceof SpeedingPoint) {
            ((SpeedingPoint)var1).setActualSpeed(var0.getDouble("actual_speed"));
        }

        if(var0.has("limit_speed") && var1 instanceof SpeedingPoint) {
            ((SpeedingPoint)var1).setLimitSpeed(var0.getDouble("limit_speed"));
        }

        if(var0.has("acceleration")) {
            if(var1 instanceof HarshAccelerationPoint) {
                ((HarshAccelerationPoint)var1).setAcceleration(var0.getDouble("acceleration"));
            } else if(var1 instanceof HarshBreakingPoint) {
                ((HarshBreakingPoint)var1).setAcceleration(var0.getDouble("acceleration"));
            }
        }

        if(var0.has("initial_speed")) {
            if(var1 instanceof HarshAccelerationPoint) {
                ((HarshAccelerationPoint)var1).setInitialSpeed(var0.getDouble("initial_speed"));
            } else if(var1 instanceof HarshBreakingPoint) {
                ((HarshBreakingPoint)var1).setInitialSpeed(var0.getDouble("initial_speed"));
            }
        }

        if(var0.has("end_speed")) {
            if(var1 instanceof HarshAccelerationPoint) {
                ((HarshAccelerationPoint)var1).setEndSpeed(var0.getDouble("end_speed"));
            } else if(var1 instanceof HarshBreakingPoint) {
                ((HarshBreakingPoint)var1).setEndSpeed(var0.getDouble("end_speed"));
            }
        }

        if(var0.has("centripetal_acceleration") && var1 instanceof HarshSteeringPoint) {
            ((HarshSteeringPoint)var1).setCentripetalAcceleration(var0.getDouble("centripetal_acceleration"));
        }

        if(var0.has("turn_type") && var1 instanceof HarshSteeringPoint) {
            ((HarshSteeringPoint)var1).setTurnType((TurnType)TurnType.valueOf(TurnType.class, var0.getString("turn_type")));
        }

        if(var0.has("speed") && var1 instanceof HarshSteeringPoint) {
            ((HarshSteeringPoint)var1).setTurnSpeed(var0.getDouble("speed"));
        }

    }

    public static boolean b(String var0, BaseResponse var1) {
        try {
            JSONObject var3;
            if((var3 = new JSONObject(var0)).has("status_sp")) {
                int var4;
                switch(var4 = var3.getInt("status_sp")) {
                    case 1:
                        var1.setStatus(var4);
                        var1.setMessage("服务内部错误");
                        break;
                    case 104:
                    case 106:
                    case 107:
                        d.a();
                        var1.setStatus(14003);
                        var1.setMessage("鉴权未完成");
                        break;
                    case 105:
                    case 108:
                        d.a();
                        var1.setStatus(14004);
                        var1.setMessage("鉴权失败");
                        break;
                    default:
                        var1.setStatus(14001);
                        var1.setMessage("请求失败");
                }

                return false;
            } else {
                if(var3.has("status")) {
                    var1.setStatus(var3.getInt("status"));
                }

                if(var3.has("message")) {
                    var1.setMessage(var3.getString("message"));
                } else if(var3.has("status")) {
                    switch(var3.getInt("status")) {
                        case 0:
                            var1.setMessage("成功");
                            break;
                        case 1:
                            var1.setMessage("服务内部错误");
                            break;
                        default:
                            var1.setMessage("服务内部错误");
                    }
                }

                return true;
            }
        } catch (Exception var2) {
            var1.setStatus(14000);
            var1.setMessage("响应解析失败");
            return false;
        }
    }

    private static void a(JSONObject var0, InternalError var1) throws JSONException {
        if(var0 != null) {
            Iterator var2 = var0.keys();
            ArrayList var3 = new ArrayList();

            while(var2.hasNext()) {
                var3.add(var2.next());
            }

            if(var0.has("entity_name")) {
                var1.setEntityName(var0.getString("entity_name"));
                var3.remove("entity_name");
            }

            if(var0.has("error")) {
                if(var1 instanceof ParamError) {
                    ((ParamError)var1).setError(var0.getString("error"));
                }

                var3.remove("error");
            }

            TrackPoint var4 = new TrackPoint();
            a((JSONObject)var0, (Point)var4, (List)var3);
            var1.setTrackPoint(var4);
        }
    }

    public static void a(JSONObject var0, Point var1, List<String> var2) throws JSONException {
        if(var0.has("longitude") && var0.has("latitude")) {
            var1.setLocation(new LatLng(var0.getDouble("latitude"), var0.getDouble("longitude")));
        }

        if(var2 != null && var2.contains("longitude")) {
            var2.remove("longitude");
        }

        if(var2 != null && var2.contains("latitude")) {
            var2.remove("latitude");
        }

        if(var0.has("coord_type")) {
            var1.setCoordType(CoordType.valueOf(var0.getString("coord_type")));
            if(var2 != null) {
                var2.remove("coord_type");
            }
        } else if(var0.has("coord_type_input")) {
            var1.setCoordType(CoordType.valueOf(var0.getString("coord_type_input")));
            if(var2 != null) {
                var2.remove("coord_type_input");
            }
        }

        if(var0.has("address")) {
            if(var1 instanceof StartPoint) {
                ((StartPoint)var1).setAddress(var0.getString("address"));
            } else if(var1 instanceof EndPoint) {
                ((EndPoint)var1).setAddress(var0.getString("address"));
            }

            if(var2 != null) {
                var2.remove("address");
            }
        }

        if(var0.has("radius")) {
            var1.setRadius(var0.getDouble("radius"));
            if(var2 != null) {
                var2.remove("radius");
            }
        }

        if(var0.has("loc_time")) {
            try {
                var1.setLocTime(Long.parseLong(var0.getString("loc_time")));
            } catch (Exception var5) {
                ;
            }

            if(var2 != null) {
                var2.remove("loc_time");
            }
        }

        if(var0.has("create_time") && var1 instanceof TrackPoint) {
            ((TrackPoint)var1).setCreateTime(var0.getString("create_time"));
            if(var2 != null) {
                var2.remove("create_time");
            }
        }

        if(var0.has("direction")) {
            var1.setDirection(var0.getInt("direction"));
            if(var2 != null) {
                var2.remove("direction");
            }
        }

        if(var0.has("speed")) {
            var1.setSpeed(var0.getDouble("speed"));
            if(var2 != null) {
                var2.remove("speed");
            }
        }

        if(var0.has("height")) {
            var1.setHeight(var0.getDouble("height"));
            if(var2 != null) {
                var2.remove("height");
            }
        }

        if(var0.has("distance") && var1 instanceof LatestLocation) {
            ((LatestLocation)var1).setDistance(var0.getDouble("distance"));
            if(var2 != null) {
                var2.remove("distance");
            }
        }

        if(var0.has("floor")) {
            if(var1 instanceof LatestLocation) {
                ((LatestLocation)var1).setFloor(var0.getString("floor"));
            } else if(var1 instanceof LatestPoint) {
                ((LatestPoint)var1).setFloor(var0.getString("floor"));
            }

            if(var2 != null) {
                var2.remove("floor");
            }
        }

        if(var0.has("object_name")) {
            if(var1 instanceof LatestLocation) {
                ((LatestLocation)var1).setObjectName(var0.getString("object_name"));
            } else if(var1 instanceof TrackPoint) {
                ((TrackPoint)var1).setObjectName(var0.getString("object_name"));
            } else if(var1 instanceof LatestPoint) {
                ((LatestPoint)var1).setObjectName(var0.getString("object_name"));
            }

            if(var2 != null) {
                var2.remove("object_name");
            }
        }

        HashMap var3 = new HashMap();
        if(var2 != null && !var2.isEmpty()) {
            Iterator var6 = var2.iterator();

            while(var6.hasNext()) {
                String var4 = (String)var6.next();
                var3.put(var4, var0.getString(var4));
            }
        }

        if(var1 instanceof LatestLocation) {
            ((LatestLocation)var1).setColumns(var3);
        } else if(var1 instanceof TrackPoint) {
            ((TrackPoint)var1).setColumns(var3);
        } else {
            if(var1 instanceof LatestPoint) {
                ((LatestPoint)var1).setColumns(var3);
            }

        }
    }

    protected static void a(AddPointRequest var0, OnTrackListener var1) {
        TreeMap var2 = new TreeMap();
        if(!TextUtils.isEmpty(var0.getEntityName())) {
            try {
                var2.put("entity_name", URLEncoder.encode(var0.getEntityName(), "UTF-8"));
            } catch (Exception var6) {
                var2.put("entity_name", var0.getEntityName());
            }
        }

        AddPointResponse var3 = new AddPointResponse(var0.getTag());
        Point var4 = var0.getPoint();
        if(var4 == null) {
            var3.setStatus(2);
            var3.setMessage("point参数错误");
            var1.onAddPointCallback(var3);
        } else {
            LatLng var5;
            if(e.a(var5 = var4.getLocation())) {
                var2.put("latitude", String.valueOf(var5.getLatitude()));
                var2.put("longitude", String.valueOf(var5.getLongitude()));
                if(var4.getLocTime() > 0L) {
                    var2.put("loc_time", String.valueOf(var4.getLocTime()));
                    if(null != var4.getCoordType()) {
                        var2.put("coord_type_input", var4.getCoordType().name());
                    }

                    var2.put("speed", String.valueOf(var4.getSpeed()));
                    var2.put("direction", String.valueOf(var4.getDirection()));
                    var2.put("height", String.valueOf(var4.getHeight()));
                    var2.put("radius", String.valueOf(var4.getRadius()));
                    if(!TextUtils.isEmpty(var0.getObjectName())) {
                        var2.put("object_name", var0.getObjectName());
                    }

                    Map var7 = var0.getColumns();
                    if(var7 != null && !a((Map)var7, (TreeMap)var2, (JSONObject)null)) {
                        var3.setStatus(2);
                        var3.setMessage("column_key参数错误");
                        var1.onAddPointCallback(var3);
                    } else {
                        com.baidu.trace.c.a.a(var0, 2, "track/addpoint", c.b, 4, a(var2, var0.getServiceId(), c.b), var1);
                        var2.clear();
                    }
                } else {
                    var3.setStatus(2);
                    var3.setMessage("locTime参数错误");
                    var1.onAddPointCallback(var3);
                }
            } else {
                var3.setStatus(2);
                var3.setMessage("location参数错误");
                var1.onAddPointCallback(var3);
            }
        }
    }

    protected static void a(AddPointsRequest var0, OnTrackListener var1) {
        TreeMap var2 = new TreeMap();
        AddPointsResponse var3 = new AddPointsResponse(var0.getTag());
        Map var4 = var0.getPoints();
        if(var4 == null) {
            var3.setStatus(2);
            var3.setMessage("pointList参数错误");
            var1.onAddPointsCallback(var3);
        } else {
            StringBuffer var5 = new StringBuffer();
            if(a(var4, var5)) {
                if(!TextUtils.isEmpty(var5)) {
                    try {
                        var2.put("point_list", URLEncoder.encode(var5.toString(), "UTF-8"));
                    } catch (Exception var6) {
                        var2.put("point_list", var5.toString());
                    }
                }

                com.baidu.trace.c.a.a(var0, 2, "track/addpoints", c.b, 5, a(var2, var0.getServiceId(), c.b), var1);
                var2.clear();
            } else {
                var3.setStatus(2);
                var3.setMessage("pointList参数错误");
                var1.onAddPointsCallback(var3);
            }
        }
    }

    protected static void a(HistoryTrackRequest var0, OnTrackListener var1) {
        TreeMap var2 = new TreeMap();
        a(var0, "track/gettrack", 1, var0.getServiceId(), var0.getEntityName(), var0.getStartTime(), var0.getEndTime(), var0.isProcessed(), var0.getProcessOption(), var0.getSupplementMode(), var0.getCoordTypeOutput(), var0.getSortType(), var0.getPageSize(), var0.getPageIndex(), var2, var1);
        var2.clear();
    }

    protected static void a(DistanceRequest var0, OnTrackListener var1) {
        TreeMap var2 = new TreeMap();
        a(var0, "track/getdistance", 2, var0.getServiceId(), var0.getEntityName(), var0.getStartTime(), var0.getEndTime(), var0.isProcessed(), var0.getProcessOption(), var0.getSupplementMode(), (CoordType)null, (SortType)null, 0, 0, var2, var1);
        var2.clear();
    }

    protected static void a(LatestPointRequest var0, OnTrackListener var1) {
        TreeMap var2 = new TreeMap();
        a(var0, "track/getlatestpoint", 3, var0.getServiceId(), var0.getEntityName(), 0L, 0L, false, var0.getProcessOption(), (SupplementMode)null, var0.getCoordTypeOutput(), (SortType)null, 0, 0, var2, var1);
        var2.clear();
    }

    private static void a(BaseRequest var0, String var1, int var2, long var3, String var5, long var6, long var8, boolean var10, ProcessOption var11, SupplementMode var12, CoordType var13, SortType var14, int var15, int var16, TreeMap<String, String> var17, OnTrackListener var18) {
        if(!TextUtils.isEmpty(var5)) {
            try {
                var17.put("entity_name", URLEncoder.encode(var5, "UTF-8"));
            } catch (Exception var19) {
                var17.put("entity_name", var5);
            }
        }

        if(var6 > 0L) {
            var17.put("start_time", String.valueOf(var6));
        }

        if(var8 > 0L) {
            var17.put("end_time", String.valueOf(var8));
        }

        var17.put("is_processed", var10?String.valueOf(1):String.valueOf(0));
        if(var12 != null) {
            var17.put("supplement_mode", var12.name());
        }

        a(var11, var17);
        if(var13 != null) {
            var17.put("coord_type_output", var13.name());
        }

        if(var14 != null) {
            var17.put("sort_type", var14.name());
        }

        if(var15 > 0) {
            var17.put("page_size", String.valueOf(var15));
        }

        if(var16 > 0) {
            var17.put("page_index", String.valueOf(var16));
        }

        com.baidu.trace.c.a.a(var0, 2, var1, c.a, var2, a(var17, var3, c.a), var18);
    }

    protected static boolean a(Map<String, String> var0, TreeMap<String, String> var1, JSONObject var2) {
        Iterator var5 = var0.entrySet().iterator();

        while(true) {
            Entry var3;
            do {
                if(!var5.hasNext()) {
                    return true;
                }

                if(!e.b((String)(var3 = (Entry)var5.next()).getKey())) {
                    return false;
                }
            } while(TextUtils.isEmpty((CharSequence)var3.getValue()));

            try {
                if(var1 != null) {
                    var1.put(var3.getKey(), URLEncoder.encode((String)var3.getValue(), "UTF-8"));
                } else if(var2 != null) {
                    var2.put((String)var3.getKey(), var3.getValue());
                }
            } catch (Exception var4) {
                if(var1 != null) {
                    var1.put(var3.getKey(), var3.getValue());
                }
            }
        }
    }

    protected static boolean a(Map<String, List<TrackPoint>> var0, StringBuffer var1) {
        if(var0 != null && var1 != null) {
            JSONArray var2 = new JSONArray();

            try {
                Iterator var9 = var0.entrySet().iterator();

                while(var9.hasNext()) {
                    Entry var3;
                    String var4 = (String)(var3 = (Entry)var9.next()).getKey();
                    List var10 = (List)var3.getValue();
                    if(var10 != null) {
                        Iterator var11 = var10.iterator();

                        while(var11.hasNext()) {
                            TrackPoint var5 = (TrackPoint)var11.next();
                            if(var5 != null) {
                                JSONObject var6;
                                (var6 = new JSONObject()).put("entity_name", var4);
                                var6.put("loc_time", var5.getLocTime());
                                LatLng var7 = var5.getLocation();
                                if(var7 != null) {
                                    var6.put("latitude", var7.getLatitude());
                                    var6.put("longitude", var7.getLongitude());
                                }

                                if(null != var5.getCoordType()) {
                                    var6.put("coord_type_input", var5.getCoordType().name());
                                }

                                var6.put("speed", var5.getSpeed());
                                var6.put("direction", var5.getDirection());
                                var6.put("height", var5.getHeight());
                                var6.put("radius", var5.getRadius());
                                var6.put("object_name", var5.getObjectName());
                                Map var12 = var5.getColumns();
                                if(var12 != null && !a((Map)var12, (TreeMap)null, (JSONObject)var6)) {
                                    return false;
                                }

                                var2.put(var6);
                            }
                        }
                    }
                }
            } catch (Exception var8) {
                return false;
            }

            var1.append(var2.toString());
            return true;
        } else {
            return false;
        }
    }

    public static void a(BaseRequest var0, int var1, boolean var2, int var3, String var4, OnTrackListener var5) {
        int var6 = var0.getTag();
        String var7 = "";
        if(var0 instanceof DistanceRequest) {
            var7 = ((DistanceRequest)var0).getEntityName();
        } else if(var0 instanceof HistoryTrackRequest) {
            var7 = ((HistoryTrackRequest)var0).getEntityName();
        } else if(var0 instanceof LatestPointRequest) {
            var7 = ((LatestPointRequest)var0).getEntityName();
        }

        String var31;
        switch(var1) {
            case 1:
                HistoryTrackResponse var29 = new HistoryTrackResponse(var6, var3, var4);
                if(var2) {
                    CoordType var10001 = ((HistoryTrackRequest)var0).getCoordTypeOutput();
                    HistoryTrackResponse var37 = var29;
                    CoordType var34 = var10001;
                    var31 = var4;
                    var34 = var34 != null?var34:CoordType.bd09ll;

                    try {
                        if(b(var31, var37)) {
                            JSONObject var28;
                            if((var28 = new JSONObject(var31)).has("total")) {
                                var37.setTotal(var28.getInt("total"));
                            }

                            if(var28.has("size")) {
                                var37.setSize(var28.getInt("size"));
                            }

                            if(var28.has("distance")) {
                                var37.setDistance(var28.getDouble("distance"));
                            }

                            if(var28.has("toll_distance")) {
                                var37.setTollDistance(var28.getDouble("toll_distance"));
                            }

                            JSONObject var32;
                            Point var38;
                            if(var28.has("start_point")) {
                                var32 = var28.getJSONObject("start_point");
                                var38 = new Point((LatLng)null, var34);
                                a((JSONObject)var32, (Point)var38, (List)null);
                                var37.setStartPoint(var38);
                            }

                            if(var28.has("end_point")) {
                                var32 = var28.getJSONObject("end_point");
                                var38 = new Point((LatLng)null, var34);
                                a((JSONObject)var32, (Point)var38, (List)null);
                                var37.setEndPoint(var38);
                            }

                            ArrayList var35 = new ArrayList();
                            if(var28.has("points")) {
                                JSONArray var39;
                                int var30 = (var39 = var28.getJSONArray("points")).length();

                                for(int var8 = 0; var8 < var30; ++var8) {
                                    JSONObject var9;
                                    Iterator var10 = (var9 = var39.getJSONObject(var8)).keys();
                                    ArrayList var11 = new ArrayList();

                                    while(var10.hasNext()) {
                                        var11.add(var10.next());
                                    }

                                    TrackPoint var40 = new TrackPoint(var34);
                                    a((JSONObject)var9, (Point)var40, (List)var11);
                                    var35.add(var40);
                                }
                            }

                            var37.setTrackPoints(var35);
                        }
                    } catch (Exception var22) {
                        ;
                    } finally {
                        ;
                    }
                }

                var29.setEntityName(var7);
                var5.onHistoryTrackCallback(var29);
                return;
            case 2:
                DistanceResponse var26 = new DistanceResponse(var6, var3, var4);
                if(var2) {
                    DistanceResponse var33 = var26;
                    var31 = var4;

                    try {
                        JSONObject var36;
                        if(b(var31, var33) && (var36 = new JSONObject(var31)).has("distance")) {
                            var33.setDistance(var36.getDouble("distance"));
                        }
                    } catch (Exception var20) {
                        ;
                    } finally {
                        ;
                    }
                }

                var26.setEntityName(var7);
                var5.onDistanceCallback(var26);
                return;
            case 3:
                LatestPointResponse var27 = new LatestPointResponse(var6, var3, var4);
                if(var2) {
                    a(var4, ((LatestPointRequest)var0).getCoordTypeOutput(), var27);
                }

                var27.setEntityName(var7);
                var5.onLatestPointCallback(var27);
                return;
            case 4:
                AddPointResponse var25 = new AddPointResponse(var6, var3, var4);
                if(var2) {
                    b(var4, var25);
                }

                var5.onAddPointCallback(var25);
                return;
            case 5:
                AddPointsResponse var24 = new AddPointsResponse(var6, var3, var4);
                if(var2) {
                    a(var4, var24);
                }

                var5.onAddPointsCallback(var24);
            default:
        }
    }
}
